<template>
    <div id="app" v-loading="loading">
        <div class="title">计划列表</div>
        <el-row class="tableBtnTop">
            <el-select 
                v-model="searchType"
                placeholder="请选择"
            >
                <el-option
                    v-for="(typeItem,typeIndex) of searchTypeList"
                    :key="typeItem.value"
                    :value="typeItem.value"
                    :label="typeItem.name"
                ></el-option>
            </el-select>
            <div class="search">
                <el-input placeholder="请输对应id值"
                    v-model.trim="searchText"
                    @keyup.enter.native="searchWill"
                >
                    <i slot="prefix" class="el-input__icon el-icon-search"
                    ></i>
                </el-input>
            </div>
        </el-row>
        <el-table :data="tableData" border
            @filter-change="handleFilter"
            ref="filterTable"
        >
            <el-table-column prop="type" label="执行内容" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                    {{
                        scope.row.type.text
                    }}
                </template>
            </el-table-column>
            <el-table-column prop="time_created" label="创建时间" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                    {{
                        countTrialDate(scope.row.time_created * 1000)
                    }}
                </template>
            </el-table-column>
            <el-table-column prop="active_time" label="系统执行时间" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                    {{
                        countTrialDate(scope.row.active_time * 1000)
                    }}
                </template>
            </el-table-column>
            <el-table-column prop="content" label="参数" :show-overflow-tooltip="true">
            </el-table-column>
            <el-table-column prop="status" label="状态" :show-overflow-tooltip="true"
                column-key="status"
                :filters="status"
            >
                <template slot-scope="scope">
                            <font v-if="tableData[scope.$index].status==0">等待执行</font>
                            <font v-else-if="tableData[scope.$index].status==1">已执行</font>
                            <font v-else>不执行</font>
                        </template>
            </el-table-column>
            <el-table-column prop="btn" label="操作" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                <div class="tableBtn">
                    <template v-if="scope.row.status==0">
                        <a @click="executePlanApi(scope.$index,0)">提前执行</a>
                        <a @click="executePlanApi(scope.$index,2)">不执行</a>
                    </template>
                    <template v-if="scope.row.status==2">
                        <a @click="executePlanApi(scope.$index,0)">继续执行</a>
                    </template>
                    <template v-if="scope.row.status==1">
                        -
                    </template>
                </div>
                </template>
            </el-table-column>
        </el-table>
        <div class="paginationBlock">
            <el-pagination layout="prev, pager, next,total" 
                :total="listNums" 
                :page-size="10"
                @current-change="changePage"
            >
            </el-pagination>
		</div>
    </div>
</template>

<script>
    import PlanList from './index.js';
    export default PlanList;
</script>
<style lang="scss" scoped>
    .title{
        margin-bottom:25px;
        font-size:21px;
        margin-top:65px;
    }
</style>